package com.ruoyi.web.controller.laiqianba.channel;

import java.util.List;
import java.util.Map;
import javax.servlet.http.HttpServletResponse;

import com.alibaba.fastjson2.JSONObject;
import com.ruoyi.db.domain.ChannelCountUvInfo;
import org.springframework.security.access.prepost.PreAuthorize;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.GetMapping;
import org.springframework.web.bind.annotation.PostMapping;
import org.springframework.web.bind.annotation.PutMapping;
import org.springframework.web.bind.annotation.DeleteMapping;
import org.springframework.web.bind.annotation.PathVariable;
import org.springframework.web.bind.annotation.RequestBody;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RestController;
import com.ruoyi.common.annotation.Log;
import com.ruoyi.common.core.controller.BaseController;
import com.ruoyi.common.core.domain.AjaxResult;
import com.ruoyi.common.enums.BusinessType;
import com.ruoyi.db.domain.ChannelCountPvInfo;
import com.ruoyi.channel.service.IChannelCountPvInfoService;
import com.ruoyi.web.wrapper.ChannelCountPvInfoWrapper;
import com.ruoyi.common.utils.poi.ExcelUtil;
import com.ruoyi.common.core.page.TableDataInfo;

/**
 * 渠道统计pv信息Controller
 * 
 * @author ruoyi
 * @date 2025-07-31
 */
@RestController
@RequestMapping("/channel/countPvInfo")
public class ChannelCountPvInfoController extends BaseController
{
    @Autowired
    private IChannelCountPvInfoService channelCountPvInfoService;

    /**
     * 查询渠道统计pv信息列表
     */
    @PreAuthorize("@ss.hasPermi('channel:countPvInfo:list')")
    @GetMapping("/list")
    public TableDataInfo list(ChannelCountPvInfo channelCountPvInfo)
    {
        startPage();
        List<Map<String, Object>> list = channelCountPvInfoService.selectChannelCountPvInfoMapList(channelCountPvInfo);
        list = new ChannelCountPvInfoWrapper(list).wrap();
        return getDataTable(list);
    }

    /**
     * 导出渠道统计pv信息列表
     */
    @PreAuthorize("@ss.hasPermi('channel:countPvInfo:export')")
    @Log(title = "渠道统计pv信息", businessType = BusinessType.EXPORT)
    @PostMapping("/export")
    public void export(HttpServletResponse response, ChannelCountPvInfo channelCountPvInfo)
    {
        List<ChannelCountPvInfo> list = channelCountPvInfoService.selectChannelCountPvInfoList(channelCountPvInfo);
        ExcelUtil<ChannelCountPvInfo> util = new ExcelUtil<ChannelCountPvInfo>(ChannelCountPvInfo.class);
        util.exportExcel(response, list, "渠道统计pv信息数据");
    }

    /**
     * 获取渠道统计pv信息详细信息
     */
    @PreAuthorize("@ss.hasPermi('channel:countPvInfo:query')")
    @GetMapping(value = "/{id}")
    public AjaxResult getInfo(@PathVariable("id") Long id)
    {
        return success(channelCountPvInfoService.selectChannelCountPvInfoById(id));
    }

    /**
     * 新增渠道统计pv信息
     */
    @PreAuthorize("@ss.hasPermi('channel:countPvInfo:add')")
    @Log(title = "渠道统计pv信息", businessType = BusinessType.INSERT)
    @PostMapping
    public AjaxResult add(@RequestBody ChannelCountPvInfo channelCountPvInfo)
    {
        return toAjax(channelCountPvInfoService.insertChannelCountPvInfo(channelCountPvInfo));
    }

    /**
     * 修改渠道统计pv信息
     */
    @PreAuthorize("@ss.hasPermi('channel:countPvInfo:edit')")
    @Log(title = "渠道统计pv信息", businessType = BusinessType.UPDATE)
    @PutMapping
    public AjaxResult edit(@RequestBody ChannelCountPvInfo channelCountPvInfo)
    {
        return toAjax(channelCountPvInfoService.updateChannelCountPvInfo(channelCountPvInfo));
    }

    /**
     * 删除渠道统计pv信息
     */
    @PreAuthorize("@ss.hasPermi('channel:countPvInfo:remove')")
    @Log(title = "渠道统计pv信息", businessType = BusinessType.DELETE)
	@DeleteMapping("/{ids}")
    public AjaxResult remove(@PathVariable Long[] ids)
    {
        return toAjax(channelCountPvInfoService.deleteChannelCountPvInfoByIds(ids));
    }

    /**
     * 查询渠道统计Pv信息列表
     * @return
     */
    @PreAuthorize("@ss.hasPermi('channel:countUvInfo:count')")
    @GetMapping("/count/list")
    public AjaxResult count(ChannelCountPvInfo channelCountPvInfo)
    {
        List<Map<String, Object>> list = channelCountPvInfoService.selectChannelCountList(channelCountPvInfo);
        JSONObject returnData = new JSONObject();
        returnData.put("dataList", list);
        return success(returnData);
    }
}
